package priv.demo3.main;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.payment.lc.pcs.common.util.DateUtil;

import java.io.File;
import java.io.FileInputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) throws Exception {
        String s = readFile("D:/tmp/bigData1");
        List<Map> maps = JSON.parseArray(s, Map.class);
        for (int i = 0; i < maps.size(); i++) {
            Map map = maps.get(i);
            Object o = ((Map) (map.get("openTradePeriod"))).get("startPurchaseDate");
            Date date = DateUtil.parseDate(o.toString(),DateUtil.longFormat);
            Date now = new Date();
            if (date.after(now)) {
                System.out.println(DateUtil.getWebDateString(date));
                System.out.println(map.get("projectID"));
            }
        }
    }


    public static String readFile(String fileName) {
        try {
            Scanner scanner = new Scanner(new FileInputStream(new File(fileName)));
            StringBuilder s = new StringBuilder();
            while (scanner.hasNextLine()) {
                s.append(scanner.nextLine());
            }
            scanner.close();
            return s.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}